#!/usr/bin/env python
######
#
# UDP Client
# by Shoufu Luo, Oct. 22, 2012
#
######


import socket,sys,threading

if __name__ == "__main__":
	if len(sys.argv) != 4:
		print "Usage: %s <target> <port> <msg>" % sys.argv[0]
		sys.exit(1)
	target=sys.argv[1]
	port=int(sys.argv[2])
	msg = sys.argv[3]

	sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
	print "Send %s to %s:%s" % (msg, target, port)
	sock.sendto(msg, (target, port))
	received = sock.recvfrom(1024)
	print "Received: ", received
